<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<script>
    $(function(){
       var type= $('#coefftype option:selected') .val();//选中的值
        if(type=='1'){
            $("#jian").css('display','block');
            $("#zhe").css('display','none');
        }
    })
    function checkType(){
        var type= $('#coefftype option:selected') .val();//选中的
        if(type=='0'){
            $("#zhe").css('display','block');
            $("#jian").css('display','none');
            $("#coeffDreate").val('0');
        }
        if(type=='1'){
            $("#jian").css('display','block');
            $("#zhe").css('display','none');
            $("#coeffMole").val('');
            $("#denominator").val('');
        }
    }
    autoCompleteFirm("itemName");
   /* function autoCompleteClinic(inputId){
        fuzhi();
        alert(chargeType+'-----2');
        var url="${ctx}/oper/priceList/autoCompleteByCharge?chargeType="+chargeType;
        autoComplete(inputId,url,
                function(data){
                    var rows = [];
                    for(var i=0; i<data.length; i++){
                        rows[rows.length] = {
                            data:data[i],
                            value:data[i].id,
                            result:data[i].itemName
                        };
                    }
                    return rows;
                },function(data, i, max){
                    return data.itemName+"|"+data.itemCode+"|"+data.price+"元 |"+data.label
                },function(event,data,formatted){
                    $("#clinicItemId").val(data.id);
                    $("#itemCode").val(data.itemCode);
                })
    }*/
    function autoCompleteFirm(inputId){
        var url="${ctx}/oper/priceList/autoCompleteByCharge";
        $("#itemName").autocomplete(url, {
            minChars: 0, //在触发autoComplete前用户至少需要输入的字符数.
            max: 20,//autoComplete下拉显示项目的个数
            autoFill: false, //要不要在用户选择时自动将用户当前鼠标所在的值填入到input框
            //mustMatch: true, //autoComplete只会允许匹配的结果出现在输入框,所有当用户输入的是非法字符时将会得不到下拉框
            matchContains: true, //决定比较时是否要在字符串内部查看匹配,如ba是否与foo bar中的ba匹配.使用缓存时比较重要.不要和autofill混用
            multipleSeparator: '',//如果是多选时,用来分开各个选择的字符.
            multiple: false, //是否允许输入多个值即多次使用autoComplete以输入多个值
            scrollHeight: 300,
            width: "20%",
            dataType: 'json',
            method: 'POST',
            onBegin: function(options) { //修改--用于动态改变ledger的值
                options.extraParams.chargeType= $('#chargeType option:selected') .val();
                return options;
            },
            parse:  function(data){
                var rows = [];
                for(var i=0; i<data.length; i++){
                    rows[rows.length] = {
                        data:data[i],
                        value:data[i].id,
                        result:data[i].itemName
                    };
                }
                return rows;
            }, formatItem: function(data, i, max){
                return data.itemName+"|"+data.itemCode+"|"+data.price+"元 |"+data.label;
            }
        }).result(function(event,data,formatted){
            $("#clinicItemId").val(data.id);
            $("#itemCode").val(data.itemCode);
        });
    }
</script>
<div class="content-wrap">
        <div class="wrapper" style="bottom: 50px;">
            <ul class="nav nav-tabs">
                <li>
                    <a href="#"  onclick="loadDiv('mainCenterDiv','${ctx}/finance/chargePriceSchedule/index')">收费系数列表</a>
                </li>
                <li class="active">
                    <a href="#" onclick="loadDiv('mainCenterDiv','${ctx}/finance/chargePriceSchedule/form')">
                        <c:choose>
                            <c:when test="${chargePriceSchedule.id==''|| chargePriceSchedule.id==null}">
                                收费系数添加
                            </c:when>
                            <c:otherwise>收费系数修改</c:otherwise>
                        </c:choose>
                    </a>
                </li>
            </ul>
            <section class="panel panel-default">
                <div class="panel-body">
                    <div class="col-lg-12">
                        <form:form id="inputForm" data-parsley-validate="" modelAttribute="chargePriceSchedule" onsubmit="return formSaveLoad('mainCenterDiv','inputForm','${ctx}/finance/chargePriceSchedule/save','${ctx}/finance/chargePriceSchedule/index');" method="post" class="form-horizontal">
                            <form:hidden path="id"/>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">费别：</label>
                                    <div class="col-sm-4">
                                        <form:select path="chargeType" id="chargeType" htmlEscape="false" class="form-control"  maxlength="64" data-parsley-required="true">
                                            <form:options items="${fns:getDictList('CHARGE_TYPE_DICT')}"  itemLabel="label" itemValue="value"  htmlEscape="false"/>
                                        </form:select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">收费项目：</label>
                                    <div class="col-sm-4">
                                        <form:hidden path="priceId" id="clinicItemId"></form:hidden>
                                        <form:input  path="itemName" htmlEscape="false" class="form-control"  maxlength="100" id="itemName" data-parsley-required="true"/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">项目编码：</label>
                                    <div class="col-sm-4">
                                        <form:input path="itemCode" id="itemCode" htmlEscape="false" class="form-control"  maxlength="200" data-parsley-required="true" disabled="true"/>
                                    </div>
                                </div>
                               <div class="form-group">
                                   <label class="col-sm-2 control-label">门诊/住院</label>
                                   <div class="col-sm-4">
                                       <form:select path="outOrIn" class="form-control"  maxlength="2" data-parsley-required="true">
                                           <form:option value="0">门诊</form:option>
                                           <form:option value="1">住院</form:option>
                                       </form:select>
                                   </div>
                               </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">优惠类型:</label>
                                    <div class="col-sm-4">
                                        <form:select path="priceCoeffType" id="coefftype" class="form-control"  maxlength="2" data-parsley-required="true" onclick="checkType()">
                                            <form:option value="0">折扣</form:option>
                                            <form:option value="1">减免</form:option>
                                        </form:select>
                                    </div>
                                </div>
                                <div class="form-group" style="display: none;" id="jian">
                                    <label class="col-sm-2 control-label">减免金额：</label>
                                    <div class="col-sm-4">
                                        <form:input path="priceCoeffDreate"  htmlEscape="false" class="form-control"  maxlength="100" id="coeffDreate" data-parsley-type="number"/>
                                    </div>
                                </div>
                                <div class="form-group" id="zhe">
                                    <label class="col-sm-2 control-label">收费折扣：</label>
                                    <div class="col-sm-2">
                                        <div class="input-group mb2">
                                         <form:input path="priceCoeffMolecular" data-Nparsley-type="number" htmlEscape="false" class="form-control"  maxlength="10" id="coeffMole"/><span class="input-group-btn"><button class="btn btn-default" type="button">分子</button></span>
                                        </div>
                                     </div>
                                    <div class="col-sm-2">
                                        <div class="input-group mb2">
                                        <form:input path="priceCoeffDenominator" htmlEscape="false" class="form-control"  maxlength="10" data-parsley-type="number" id="denominator"/><span class="input-group-btn"><button class="btn btn-default" type="button">分母</button></span>
                                        </div>
                                     </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-sm-offset-2 col-sm-10">
                                        <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存">&nbsp;
                                        <input id="btnCancel" class="btn" type="button" value="返 回" onclick="loadDiv('mainCenterDiv','${ctx}/finance/chargePriceSchedule/index')">
                                </div>
                            </div>
                        </form:form>
                    </div>

                </div>
            </section>
        </div>
    </div>